<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//服务器的动态网页中禁止缓存
response.setHeader("Pragma","No-cache"); 
response.setHeader("Cache-Control","no-cache"); 
response.setDateHeader("Expires", 0);  
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>Heat Meter Model and Parameter Configuration</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>beshs/css/content.css" />
	<script type="text/javascript" src="<%=basePath%>resources/jquery/jquery-1.7.2.min.js"></script>
	<!-- 页面特效 -->
	<jsp:include page="/beshs/res-refer/page-effect-reference.jsp" />
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- 表单校验 -->
	<jsp:include page="/resources/resource-refer/component-validform-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
  </head>
  <script type="text/javascript">
  	function submitForm() {
  		var typeParamUID = "<s:property value='typeParamUID' />";
  		//表单信息
  		var typeCode = $("input[name='typeCode']").val();
  		typeCode = $.trim(typeCode);
  		var settleAccountHeatPrecision = $("input[name='settleAccountHeatPrecision']").val();
  		var sumHeatPrecision = $("input[name='sumHeatPrecision']").val();
  		var heatPowerPrecision = $("input[name='heatPowerPrecision']").val();
  		var instantFlowPrecision = $("input[name='instantFlowPrecision']").val();
  		var sumFlowPrecision = $("input[name='sumFlowPrecision']").val();
  		var supplyTemperaturePrecision = $("input[name='supplyTemperaturePrecision']").val();
  		var backTemperaturePrecision = $("input[name='backTemperaturePrecision']").val();
  		var runHoursPrecision = $("input[name='runHoursPrecision']").val();
  		var remark = $("textarea[name='remark']").val();
  		$.getJSON(path+"beshs/heatMeterTypeParamDictActionJson!saveOrUpdateTypeParamDict.do?date="+new Date(), {
  			"typeParam.id": typeParamUID,
  			"typeParam.typeCode": typeCode,
  			"typeParam.settleAccountHeatPrecision": settleAccountHeatPrecision,
  			"typeParam.sumHeatPrecision": sumHeatPrecision,
  			"typeParam.heatPowerPrecision": heatPowerPrecision,
  			"typeParam.instantFlowPrecision": instantFlowPrecision,
  			"typeParam.sumFlowPrecision": sumFlowPrecision,
  			"typeParam.supplyTemperaturePrecision": supplyTemperaturePrecision,
  			"typeParam.backTemperaturePrecision": backTemperaturePrecision,
  			"typeParam.runHoursPrecision": runHoursPrecision,
  			"typeParam.remark": remark
  		}, function(data){
  			if(data.success) {
  				Dialog.alert("Successful Operation！", function() {
  					var index = parent.layer.getFrameIndex(window.name)
					parent.window.frames["c_content_content"].location = path + "beshs/heatMeterTypeParamDictAction!queryMeterTypeParamPage.do?date"+new Date();
  					parent.layer.close(index);
  				});
  			} else {
  				Dialog.alert(data.msg);
  			}
  		});
  	}
  	
  	$(function(){
		$("form[name='meterPrecisionForm']").Validform({
			btnSubmit: "input[name='submit']",
			btnReset: "input[name='reset']",
			tiptype: function(msg, o, cssctl){
				//msg：提示信息;
				//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
				//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
				if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
					var objtip=o.obj.siblings(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				} else {
					var objtip=o.obj.find("#msgdemo");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
			},
			postonce: true, //开启二次提交防御，在数据成功提交后，表单将不能再继续提交
			showAllError: true, //提交表单时所有错误提示信息都会显示
			beforeSubmit: function(curform) { //在验证成功后，表单提交前执行的函数，curform参数是当前表单对象
				submitForm();
				return true; //这里明确return false的话表单将不会提交
			}
		});
  	});
  </script>
  <body>
    <div class="content_all">
  		<!--导航条-->
  		<div class="insertinfo_table">
      		<form action="#" name="meterPrecisionForm"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        		<tr>
          			<th>Heat Meter Model No.：</th>
          			<td><input name="typeCode" type="text" class="s_input" value="<s:property value='typeParam.typeCode' />" 
          					ajaxurl="<%=basePath%>beshs/formAsyncValidateActionJson!validTypeCodeUnique.do?entityUuid=<s:property value='typeParam.id' />"
          					datatype="/^[0-9a-zA-Z]{1,40}$/" sucmsg="Heat Meter Model No. Verification Passed！" nullmsg="Please enter heat meter model no.！" errormsg="Heat meter model no. only can be composed of letters,numbers and dashes within 1~40 characters！"/>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Heat meter model no. only can be composed of letters,numbers and dashes within 1~40 characters！</div></td>
            		<th>Heat Accuracy on Settlement Day：</th>
          			<td>
          				<input name="settleAccountHeatPrecision" type="text" class="s_input" value="<s:property value='typeParam.settleAccountHeatPrecision' />" 
          					datatype="/^[1-9]\d*|0$/" ignore="ignore" errormsg="Postitive integer or 0！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip">Do not fill in accuracy, defaulted as 0.</div></td>
        		</tr>
        		<tr>
          			<th>Accumulated Heat Accurracy：</th>
          			<td>
          				<input name="sumHeatPrecision" type="text" class="s_input" value="<s:property value='typeParam.sumHeatPrecision' />" 
          					datatype="/^[1-9]\d*|0$/" ignore="ignore" errormsg="Postitive integer or 0！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip">Do not fill in accuracy, defaulted as 0!</div></td>
            		<th>Heat Power Accurracy：</th>
          			<td>
          				<input name="heatPowerPrecision" type="text" class="s_input" value="<s:property value='typeParam.heatPowerPrecision' />" 
          					datatype="/^[1-9]\d*|0$/" ignore="ignore" errormsg="Postitive integer or 0！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip">Do not fill in accuracy, defaulted as 0！</div></td>
        		</tr>
        		<tr>
          			<th>Instantaneous Heat Accuracy：</th>
          			<td>
          				<input name="instantFlowPrecision" type="text" class="s_input" value="<s:property value='typeParam.instantFlowPrecision' />" 
          					datatype="/^[1-9]\d*|0$/" ignore="ignore" errormsg="Postitive integer or 0！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip">Do not fill in accuracy, defaulted as 0！</div></td>
            		<th>Accumulated Flow Accurracy：</th>
          			<td>
          				<input name="sumFlowPrecision" type="text" class="s_input" value="<s:property value='typeParam.sumFlowPrecision' />" 
          					datatype="/^[1-9]\d*|0$/" ignore="ignore" errormsg="Postitive integer or 0！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip">Do not fill in accuracy, defaulted as 0！</div></td>
        		</tr>
        		<tr>
          			<th>Supply Water Temperature Accuracy：</th>
          			<td>
          				<input name="supplyTemperaturePrecision" type="text" class="s_input" value="<s:property value='typeParam.supplyTemperaturePrecision' />" 
          					datatype="/^[1-9]\d*|0$/" ignore="ignore" errormsg="Postitive integer or 0！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip">Do not fill in accuracy, defaulted as 0！</div></td>
            		<th>Return Water Temperature Accuracy：</th>
          			<td>
          				<input name="backTemperaturePrecision" type="text" class="s_input" value="<s:property value='typeParam.backTemperaturePrecision' />" 
          					datatype="/^[1-9]\d*|0$/" ignore="ignore" errormsg="Postitive integer or 0！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip">Do not fill in accuracy, defaulted as 0！</div></td>
        		</tr>
        		<tr>
          			<th>Accumulated Operating Time Accuracy：</th>
          			<td>
          				<input name="runHoursPrecision" type="text" class="s_input" value="<s:property value='typeParam.runHoursPrecision' />" 
          					datatype="/^[1-9]\d*|0$/" ignore="ignore" errormsg="Postitive integer or 0！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip">Do not fill in accuracy, defaulted as 0！</div></td>
            		<th></th>
          			<td></td>
        		</tr>
        		<tr>
        			<th>Remark：</th>
          			<td colspan="3">
          				<textarea name="remark" cols="45" rows="3"
          					datatype="*1-200" ignore="ignore" errormsg="Invalid input!  please input valid content ,no more than 200pcs character">
          					<s:property value='typeParam.remark' /></textarea>
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<td style="border:none;" colspan="4" align="center">
          				<input name="submit" type="button" value="Submit" class="s_btn" />
            			<input name="reset" type="reset" value="Reset" class="s_btn"/></td>
        		</tr>
      		</table></form>
  		</div>
	</div>
	<div class="clear"></div>
  </body>
</html>
